class Watcher{
    constructor(vm,key,cb){
        this.vm=vm;
        //date中是属性key
        this.key=key;
        this.cb=cb
        //把Watcher类纪律到dep类的静态属性target中
        //触发get方法 在get中就回调用addsub
        Dep.target=this;
        this.oldValue=vm[key];
        Dep.target=null;
    }
    update(){
        let newval=this.vm[this.key];
        if(newval===this.oldValue){
            return
        }
        this.cb(newval)
    }

}